/* 
 * Copyright (C) 2013 Vitaljok
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package lv.llu.rembot.ctr;

import javax.xml.bind.JAXBException;
import lv.llu.rembot.ctr.client.RemBotFrame;
import lv.llu.rembot.ctr.server.RemBotServiceImpl;
import lv.llu.rembot.ctr.server.ServerConfig;
import lv.llu.rembot.ctr.utils.Debug;

/**
 *
 * @author Vitaljok
 */
public class RemBotCtr {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws JAXBException, InterruptedException {
        System.setProperty("java.util.logging.config.file", "logging.properties");

//        JAXBContext xml = JAXBContext.newInstance(MySingleton.class);
//        Marshaller marsh = xml.createMarshaller();
//        marsh.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
//        
//        MySingleton.getInstance().fieldA = "aaa";
//        MySingleton.getInstance().fieldB = "bbb";
//        marsh.marshal(MySingleton.getInstance(), new File("test.xml"));

//        System.out.println(MySingleton.getInstance() + "\t"+MySingleton.getInstance().fieldA);
//
//        JAXBContext xml = JAXBContext.newInstance(MySingleton.class);
//        Unmarshaller unmarsh = xml.createUnmarshaller();
//        unmarsh.unmarshal(new File("test.xml"));
//
//        System.out.println(MySingleton.getInstance() + "\t"+MySingleton.getInstance().fieldA);

        if (args.length > 0 && args[0].equals("-server")) {
            System.out.println(ServerConfig.getInstance());
            Debug.log.info("Starting RemBotCtr server");
            RemBotServiceImpl service = new RemBotServiceImpl();
            service.start();

            System.out.println(ServerConfig.getInstance());
        } else {
            Debug.log.info("Starting RemBotCtr GUI");
            new RemBotFrame().setVisible(true);
        }



    }
}
